<%--
 *  File:    ORGCopyContact.jsp
 *  @Author: jianlin wang 
 *  Date:    2005-3-7 12:17
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
 

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<%
  	Category cat = Category.getInstance("jsp.OrgCopyEdit");  
%>

<%
	String strModuleName = "IMG";
	String privilegeCode = "Z0821";
    HashMap userInfo = (HashMap)session.getAttribute("userinfo");
    int intOrgid =((Integer)userInfo.get("orgid")).intValue();  	
  	
%>


<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>ORGCopyContact.jsp</title>
<PageFlow:CheckPageFlow pageName="porgcopycontact"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../js/ScriptLib.js"></script>
<script language="JavaScript" src="../js/FuncLib.js"></script>
<%
  String strIsNew=(String)pageContext.getAttribute("isnew");
  boolean isNew="Y".equals(strIsNew);
%>
<script>
function isAllEnglish(s)	//Is the string s all English? All English:return true.
{
	var i,c;
	for(i=0;i<s.length;i++)
	{
		c=s.charAt(i);
		if((c>="A"&&c<="Z")||(c>="a"&&c<="z")||c=="_"||(c>=0&&c<=9))
		{
			if(c==" ")
				return false;
			continue;
		}
		else
			return false;
	}
	return true;
}
function page_save()
{
  if(!checkForm(thisform)) return;
  if(!isAllEnglish(thisform.adminname.value))
  {
    	alert("<%= message.getMessageDesc("ILLEGAL_FORMAT",label.getLabelName("L_AdmUserName",false)) %>");
    	return false;
  }  
  	
  if((thisform.adminname.value.length > 12)||(thisform.adminname.value.length < 4))
  {
    	alert("<%= message.getMessageDesc("LENGTH_MUST_BETWEEN",label.getLabelName("L_AdmUserName",false),"4", "12") %>");
    	return false;
  }
  if(thisform.adminpwd.value != thisform.adminpwdconfirm.value)
  {
    alert("<%= message.getMessageDesc("DIFFERENT_PASSWORD") %>");
    return ;
  } 
  if(thisform.adminpwd.value == thisform.adminname.value)
  {
    alert("<%= message.getMessageDesc("VALUE_MUST_NOTEQUAL",label.getLabelName("L_AdmPassword",false),label.getLabelName("L_AdmUserName",false)) %>");
    return ;
  } 
  var isnew = <%=JspHelper.filterNull( isNew )%>;
  if(isnew || (!isnew && !isEmpty(thisform.adminpwd.value)))
  {
    if((thisform.adminpwd.value.length > 16) || (thisform.adminpwd.value.length < 4))
    {
    	alert("<%= message.getMessageDesc("LENGTH_MUST_BETWEEN",label.getLabelName("L_AdmPassword",false),"4", "16") %>");
    	return;
    }	
    if(isCharsInBag(thisform.adminpwd.value,"0123456789"))
  	{
	  	alert("<%= message.getMessageDesc("VALUE_MUST_NOT_BE_ALL_NUMBER",label.getLabelName("L_AdmPassword",false)) %>");
		 	return;
	  }     
  }
  thisform.actionname.value="save";
  thisform.target = "_parent";
  isRunning = true;
  thisform.submit();  
  
}
function page_userselect()
{
 
  var strUrl='UserSelectPop.jsp?<%= OvalTools.randomURL() %>&orgid=<%=JspHelper.filterNull(intOrgid)%>';
  var strStatus='height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no';
  popwindow=window.open(strUrl,'newwindow',strStatus);
}
function page_setUser(id,name)
{   
    thisform.sourceusername.value= name;
    thisform.sourceuserid.value= id;
  
}


function page_orgchange(stype)
{
  var objid=eval("thisform."+stype+"orgid");
  var objcode=eval("thisform."+stype+"orgcode");
  var objname=eval("thisform."+stype+"orgname");
  objid.value="";
  objname.value="";
  if(!isEmpty(objcode.value))
  {
    thisform.reloadtype.value=stype;
    thisform.actionname.value="reload";
    thisform.target = "_self";
  	isRunning = true;
  	thisform.submit(); 
  }
}

function add_user()
{  thisform.actionname.value="adduserinit";
   thisform.target = "_self";
   isRunning = true;
   thisform.submit(); 
}
function page_add()
{    if(!checkForm(thisform)) return;
     if(isEmpty(thisform.contactname.value))
     {
         alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_ContactName",false) )%>");
         return false;
     }

    if((!emailCheck(thisform.email.value))&&(!isEmpty(thisform.email.value)))
    {
        alert("<%= message.getMessageDesc("ILLEGAL_FORMAT",label.getLabelName("L_Email",false) )%>");
        return false;
    }    
  
   thisform.actionname.value="add";
   thisform.target = "_self";
   isRunning = true;
   thisform.submit(); 
}
function  page_done()
{  if(!checkForm(thisform)) return;
   for(var i =0;i<thisform.numrows.value;i++)
  {   var uname=eval("thisform.username" + i);
      var pwd=eval("thisform.password" + i);
      var pwdc=eval("thisform.passwordcomfirm" + i);
      if(pwd.value != pwdc.value)
      {
         alert("<%= message.getMessageDesc("DIFFERENT_PASSWORD") %>");
         return ;
       }
       if((uname.value.length > 12)||(uname.value.length < 4))
      {
    	    alert("<%= message.getMessageDesc("LENGTH_MUST_BETWEEN",label.getLabelName("L_NewUser",false),"4", "12") %>");
    	    return false;
      }
   //   if((pwd.value.length > 16) || (pwd.value.length < 4))
   //   {
   // 	    alert("<%= message.getMessageDesc("LENGTH_MUST_BETWEEN",label.getLabelName("L_AdmPassword",false),"4", "16") %>");
   // 	    return;
   //   } 
   }
   thisform.actionname.value="done";
   thisform.target = "_self";
   isRunning = true;
   thisform.submit(); 
}
function page_delete()
{  

   
   if (isNullChecked(thisform.workids))
   {
    alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
    return;
   }

  if(!confirm('<%=message.getMessageDesc("ARE_YOU_SURE_DEL")%>'))
  {
       return;
  }
  thisform.actionname.value = "delete";
  thisform.target = "_self";
  isRunning = true;
  thisform.submit();

}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"  Scroll=no >
<form name="thisform" method="post" action="../Dispatcher"  target="_parent">
          <input type="hidden" name="pagename" value="porgcopycontact">
          <input type="hidden" name="actionname">
          <custom:hidden property="orgcopyid"/>
          <input type="hidden" name="orgid" value=<%=JspHelper.filterNull(intOrgid)%> >
          <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">

<table id="topTable" border=0 cellpadding=0 cellspacing=0 width="100%">
  <tr> 
    <td valign=top>
        <table border=0 cellpadding=1 cellspacing=0 width="100%">
         
          <tbody> 
          <tr> 
            <td bgcolor=#000000 style="PADDING-BOTTOM: 1px; PADDING-LEFT: 1px; PADDING-RIGHT: 1px; PADDING-TOP: 0px"> 
              <table bgcolor=#000000 border=0 cellpadding=0 cellspacing=0 width="100%">
                <tr> 
                  <td  bgcolor=#ffffff style="PADDING-BOTTOM: 3px; PADDING-LEFT: 3px; PADDING-RIGHT: 3px; PADDING-TOP: 3px"> 
                   <div id=div2 style="HEIGHT: 400px; OVERFLOW: auto"> 
                      <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">
                         <% 
                             Vector CopyContactInfo = (Vector)pageContext.getAttribute("copycontactinfo");
                             if(CopyContactInfo  == null)
                             {
                                 CopyContactInfo  = new Vector();
                             }
                             String strClassType="td-listrom";
                             int j=0;
                             
                             int intSize = CopyContactInfo.size();  
                          %>
                          
                          <tr> 
                            <td colspan="12" class="td_right">
                              <a onclick="page_add();"><custom:button type="2" label="L_Add" imgsrc="add.gif" border="0" /></a>
                              <% 
                                  if(intSize!=0){
                              %>
                              <a onclick="page_delete()"><custom:button type="2" label="L_Delete" imgsrc="delete.gif" border="0" /></a>
                              <%
                                  }
                              %>
                            </td>
                          </tr>
                          <tr class="deepblue-left"> 
                            <td class="title_center" width="25">&nbsp;</td>
                            <td class="title_center" width="100"><%= label.getLabelName("L_ContactCode") %></td>
                            <td class="title_center" width="140" ><%= label.getLabelName("L_ContactName") %><span class="red">*</span></td>
                            <td class="title_center" width="100"><%= label.getLabelName("L_Gender") %><span class="red">*</span></td>
                            <td class="title_center" width="100"><%= label.getLabelName("L_Address") %><span class="red">*</span></td>
                            <td class="title_center" width="100"><%= label.getLabelName("L_Type") %><span class="red">*</span></td>
                            <td class="title_center" width="100"><%= label.getLabelName("L_Email") %></td>
                            <td class="title_center" width="100"><%= label.getLabelName("L_Telephone") %></td>
                          </tr>
    
                          <logic:iterate id="CopyContacItems" collection="<%=CopyContactInfo %>" indexId="idx">  
                             
                              <tr onmouseover="this.className='tr-over'" onmouseout="this.className='<%=JspHelper.filterNull(strClassType)%>'"   class="<%=JspHelper.filterNull(strClassType)%>">          
                                <td><input type="checkbox" name="workids"  value="<custom:write name="CopyContacItems" property="orgcopycontactid"  />" class="normalradio" ><input type="hidden" name="orgcopycontactid<%=JspHelper.filterNull(j )%>" value="<custom:write name="CopyContacItems" property="orgcopycontactid"  />"></td>
                                <td><custom:write name="CopyContacItems" property="contactcode" nbsp="true" /></td>
                                <td><custom:write name="CopyContacItems" property="contactname" nbsp="true" /></td>
                                <td><custom:write name="CopyContacItems" property="gendername" nbsp="true" /></td>
                                <td><custom:write name="CopyContacItems" property="addressname" nbsp="true" /></td>
                                <td><custom:write name="CopyContacItems" property="contactroletypeame" nbsp="true" /></td>
                                <td><custom:write name="CopyContacItems" property="email" nbsp="true" /></td>
                                <td><custom:write name="CopyContacItems" property="officephone" nbsp="true" /></td>
                             </tr>
                               
                             <% j++; %>
                          </logic:iterate>
                              <input type="hidden" name="numrows" value=<%=JspHelper.filterNull(CopyContactInfo.size())%>>                          
                          <tr>
                             <td>&nbsp;</td>
                             <td><custom:text name="addcopycontactinfo" property="contactcode" /></td>
                              <td> <custom:text name="addcopycontactinfo" property="contactname" /></td>
                              <td><custom:select optionsName="genderinfo" optionValueKey="value"   optionInnerTextKey="valuename"  name="addcopycontactinfo"  property="gender" /></td>
                              <td><custom:select optionsName="addressinfo" optionValueKey="orgcopyaddressid"   optionInnerTextKey="addressname" name="addcopycontactinfo"  property="orgcopyaddressid" style="width:100"/></td> 
                              <td><custom:select optionsName="contacttypeinfo" optionValueKey="value"   optionInnerTextKey="valuename"  name="addcopycontactinfo"  property="contactroletype" /></td>   
                              <td><custom:text name="addcopycontactinfo" property="email" /></td>
                              <td><custom:text name="addcopycontactinfo" property="officephone" /></td>
                          </tr>  
                      </table>
                    </div>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
          </tbody> 
         
        </table>
    </td>
  </tr>
  <tr> 
    <td class=summary_top></td> 
  </tr>
  <%@include file="OrgCopyBtn.inc"%>
</table>
</form>
</body>
</html>
